/**
 * 
 */
package org.mspring.crm.server;

import java.util.List;

import org.mspring.crm.client.common.ItemType;
import org.mspring.crm.client.model.ItemModel;
import org.mspring.crm.client.remote.ItemRemote;
import org.mspring.crm.entity.permission.Item;
import org.mspring.crm.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Gao Youbo
 * @since 2012-3-5
 * 
 */
@Service("itemRemote")
public class ItemRemoteImpl extends BaseRemote implements ItemRemote {

    private ItemService itemService;

    @Autowired
    public void setItemService(ItemService itemService) {
        this.itemService = itemService;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * org.mspring.crm.client.remote.ItemRemote#generateTreeItem(java.lang.Integer
     * )
     */
    @Override
    public List<ItemModel> generateTreeItem(Integer userId, Integer parentId) {
        // TODO Auto-generated method stub
        List<Item> items = itemService.generateTreeItem(userId, parentId);
        return convertToModel(items);
    }

    /* (non-Javadoc)
     * @see org.mspring.crm.client.remote.ItemRemote#findTabItem(java.lang.Integer)
     */
    @Override
    public List<ItemModel> findTabItem(Integer parentId) {
        // TODO Auto-generated method stub
        List<Item> items = itemService.findItemByTypeAndParent(parentId, ItemType.tabitem);
        return convertToModel(items);
    }

    /* (non-Javadoc)
     * @see org.mspring.crm.client.remote.ItemRemote#findPanelItem(java.lang.Integer)
     */
    @Override
    public List<ItemModel> findPanelItem(Integer parentId) {
        // TODO Auto-generated method stub
        List<Item> items = itemService.findItemByTypeAndParent(parentId, ItemType.panelitem);
        return convertToModel(items);
    }

}
